package su.jet.common.irc.protocol.request;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;

import su.jet.common.irc.domain.User;
import su.jet.common.irc.protocol.Session;
import su.jet.irc.server.service.DataService;

@SuppressWarnings("serial")
public class GetHistoryRequest implements Request {

	private User user;
	private int period;
	
	public GetHistoryRequest(int period, User user) {
		this.period = period;
		this.user = user;
	}

	@Override
	public void process(Session session, Set<User> regUsers,
			Map<User, Session> onlineUsers, DataService dataService) throws IOException {
		
		List<String> history = dataService.getHistoryFromPeriod(user, period);
		session.sendObject(history);
		
	}
}
